<template>
	<view class="my-userinfo-container">
		<view class="top-box">
			<image :src="userinfo.avatarUrl" class="headimg"></image>
			<view class="nickname">{{userinfo.nickName}}</view>
		</view>
		<view class="panel">
			<view class="panel-title">我的服务</view>
			<view class="pannel-body">
				<view class="pannel-item" @click="gotoOrderList">
					<view><uni-icons customPrefix="order" type="icon-hsjcyyjl" size="40"></uni-icons></view>
					<text>预约记录</text>
				</view>
				<view class="pannel-item" @click="gotoResult">
					<view><uni-icons customPrefix="order" type="icon-hsjcyuyuejiluchaxun-lan" size="40"></uni-icons></view>
					<text>报告查询</text>
				</view>
				<view class="pannel-item" @click="gotoMessage">
					<view><uni-icons customPrefix="order" type="icon-hsjcwodexiaoxi" size="40"></uni-icons></view>
					<text>我的消息</text>
				</view>
			</view>
		</view>
		<view class="logout" @click="logout">退出登录</view>
	</view>
</template>

<script>
	import {mapState,mapMutations} from 'vuex'
	export default {
		name:"my-userinfo",
		data() {
			return {
				
			};
		},
		computed:{
			...mapState('m_user',['userinfo','openid'])
		},
		methods:{
			...mapMutations('m_user',['updateUserInfo','updateToken','updateOpenid']),
			//退出登录
			async logout(){
				const [err,res] = await uni.showModal({
					title:'提示',
					content:'确认退出登陆吗?'
				}).catch(err =>err)
				
				if(res && res.confirm){
					this.updateUserInfo({})
					this.updateToken('')
					this.updateOpenid('')
				}
			},
			
			gotoOrderList(){
				uni.navigateTo({
					url:'/subpkg/order_list/order_list'
				})
			},
			
			gotoResult(){
				uni.navigateTo({
					url:'/subpkg/order_result/order_result'
				})
			},
			
			gotoMessage(){
				uni.navigateTo({
					url:'/subpkg/my-message/my-message'
				})
			}
		}
	}
</script>

<style lang="scss">
.my-userinfo-container{
	height: 100%;
	background-color: #F4F4F4;
	.top-box{
		height: 200px;
		background-color: #C00000;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		.headimg{
			width: 90px;
			height: 90px;
			border-radius: 45px;
			border: 2px solid #FFFFFF;
			box-shadow: 0 1px 5px black;
		}
		.nickname{
			font-size: 16px;
			color: #FFFFFF;
			font-weight: bold;
			margin-top: 10px;
		}
	}
	
}
.panel{
	padding: 10px 10px;
	background-color: #FFFFFF;
	.panel-title{}
	.pannel-body{
		display: flex;
		justify-content: space-around;
		align-items: center;
		text-align: center;
		padding-top: 20px;
		.pannel-item{
			flex-direction: column;
		}
	}
}
.logout{
	margin-top: 20px;
	margin-left: 15px;
	width: 90%;
	border: 1px solid #C00000;
	border-radius: 5px;
	background-color: #AFAFAF;
	height: 50px;
	font-size: 20px;
	color: #000000;
	line-height:50px;
	text-align: center;
}
</style>
